package com.ham.mud.commands;

import com.ham.mud.ServerConnection;

/**
 * Created by hlucas on Jun 16, 2011 at 5:22:23 PM
 */
public class ColorCommand extends PlayerCommand {

    @Override
    protected String getCommandName() {
        return "color";
    }
    
    @Override
    public void execute(ServerConnection connection, String[] params) {
        if(params.length == 0) {
            connection.getPlayer().setColorEnabled(!connection.getPlayer().isColorEnabled());
        } else {
            String onOff = params[0].toLowerCase();

            if(onOff.equals("on")) {
                connection.getPlayer().setColorEnabled(true);
            } else if(onOff.equals("off")) {
                connection.getPlayer().setColorEnabled(false);
            } else {
                connection.printSolo("Valid options are \"on\" or \"off\". Typing the color command alone with toggle.");
            }
        }

        boolean color = connection.getPlayer().isColorEnabled();

        if(color) {
            connection.printSolo("{x_.{r,-{R=~{y+^{Y'`{W*COLOR*{Y`'{y^+{R~={r-,{x._");
        } else {
            connection.printSolo("Color is now disabled.");
        }
    }
}
